<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-demo__hzmemberwithdrawflow}">
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
        <el-form-item>
          <el-input v-model="dataForm.userName" placeholder="pc账号" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="dataForm.address" placeholder="提现地址" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-select v-model="dataForm.checkStatus" :placeholder="$t('withdraw.checkStatus')" clearable>
            <el-option :label="$t('withdraw.checkStatus1')" :value="1"></el-option>
            <el-option :label="$t('withdraw.checkStatus2')" :value="2"></el-option>
            <el-option :label="$t('withdraw.checkStatus3')" :value="3"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button @click="getDataList()">{{ $t('query') }}</el-button>
        </el-form-item>
        <!--<el-form-item>-->
          <!--<el-button type="info" @click="exportHandle()">{{ $t('export') }}</el-button>-->
        <!--</el-form-item>-->
        <!--<el-form-item>-->
          <!--<el-button v-if="$hasPermission('demo:hzmemberwithdrawflow:save')" type="primary" @click="addOrUpdateHandle()">{{ $t('add') }}</el-button>-->
        <!--</el-form-item>-->
        <!--<el-form-item>-->
          <!--<el-button v-if="$hasPermission('demo:hzmemberwithdrawflow:delete')" type="danger" @click="deleteHandle()">{{ $t('deleteBatch') }}</el-button>-->
        <!--</el-form-item>-->
      </el-form>
      <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" style="width: 100%;">
        <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
        <!--<el-table-column prop="id" label="序号" header-align="center" align="center" visible = false></el-table-column>-->
        <el-table-column prop="userName" label="pc账号" header-align="center" align="center"></el-table-column>
        <el-table-column prop="num" label="数量" header-align="center" align="center"></el-table-column>
        <el-table-column prop="toAddress" label="提现地址" header-align="center" align="center"></el-table-column>
        <el-table-column prop="createTime" label="申请时间" header-align="center" align="center"></el-table-column>
        <el-table-column prop="checkStatus" label="审核状态" header-align="center" align="center">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.checkStatus === 1" size="small" type="warning">待审核</el-tag>
            <el-tag v-if="scope.row.checkStatus === 2" size="small" type="success">通过</el-tag>
            <el-tag v-if="scope.row.checkStatus === 3" size="small" type="danger">拒绝</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="checkTime" label="审核时间" header-align="center" align="center"></el-table-column>

        <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
          <template slot-scope="scope">
            <el-button v-if="scope.row.checkStatus === 1" type="success" size="small" @click="checkSuccess(scope.row.id)">{{ $t('withdraw.checkStatus2') }}</el-button>
            <el-button v-if="scope.row.checkStatus === 1" type="danger"  size="small" @click="checkFail(scope.row.id)">{{ $t('withdraw.checkStatus3') }}</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="page"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="limit"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle">
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <!--<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>-->
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
export default {
  mixins: [mixinViewModule],
  data () {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/hz/memberwithdrawflow/page',
        getDataListIsPage: true,
        exportURL: '/hz/memberwithdrawflow/export',
        deleteURL: '/hz/memberwithdrawflow',
        deleteIsBatch: true,
        checkSuccess: '/hz/memberwithdrawflow/success/',
        checkFail: '/hz/memberwithdrawflow/fail/'
      },
      dataForm: {
          userName: '',
          checkStatus: null,
          address:''
      }
    }
  },
  components: {
    // AddOrUpdate
  },
  methods: {
      checkSuccess(id) {

          this.$confirm(this.$t('prompt.info', {'handle': this.$t('withdraw.checkStatus2')}), this.$t('prompt.title'), {
              confirmButtonText: this.$t('confirm'),
              cancelButtonText: this.$t('cancel'),
              type: 'warning'
          }).then(() => {
              this.$http['get'](`${this.mixinViewModuleOptions.checkSuccess}` + id).then(({ data: res }) => {
                  if (res.code !== 0) {
                      return this.$message.error(res.msg)
                  }
                  this.$message({
                      message: this.$t('prompt.success'),
                      type: 'success',
                      duration: 500,
                      onClose: () => {
                          this.query()
                      }
                  })
              }).catch(() => {
              })
          }).catch(() => {
          })
      },
      checkFail(id) {

          this.$confirm(this.$t('prompt.info', {'handle': this.$t('withdraw.checkStatus3')}), this.$t('prompt.title'), {
              confirmButtonText: this.$t('confirm'),
              cancelButtonText: this.$t('cancel'),
              type: 'warning'
          }).then(() => {
              this.$http['get'](`${this.mixinViewModuleOptions.checkFail}` + id).then(({ data: res }) => {
                  if (res.code !== 0) {
                      return this.$message.error(res.msg)
                  }
                  this.$message({
                      message: this.$t('prompt.success'),
                      type: 'success',
                      duration: 500,
                      onClose: () => {
                          this.query()
                      }
                  })
              }).catch(() => {
              })
          }).catch(() => {
          })
      }
  }
}
</script>
